package qx.hyj.petrescue.VO;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import lombok.Data;
import lombok.NoArgsConstructor;
import qx.hyj.petrescue.entity.Comment;

import java.time.LocalDateTime;

@Data
@NoArgsConstructor
public class CommentVo {
    private Integer id;
    /**
     * 帖子ID
     */
    private Integer cblog;
    /**
     * 评论者ID
     */
    private Integer cuser;
    /**
     * 评论内容
     */
    private String comment;
    /**
     * 评论时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")  //json序列化格式
    @JsonDeserialize(using = LocalDateTimeDeserializer.class) // 反序列化
    @JsonSerialize(using = LocalDateTimeSerializer.class)     // 序列化
    private LocalDateTime ctime;
    private String cuserName;
    private String cuserAvatar;
    public CommentVo(Comment comment) {
        this.id = comment.getId();
        this.cblog = comment.getCblog();
        this.cuser = comment.getCuser();
        this.comment = comment.getComment();
        this.ctime = comment.getCtime();
    }

}
